#include "state.h"
#include "work.h"
void MorningState::update(std::shared_ptr<Work> work)
{
    if (work->getHour() < 12)
    {
        std::cout << "当前时间" << work->getHour() << "精神百倍！" << std::endl;
    }
    else
    {
        std::shared_ptr<State> aa(new NoonState);
        work->setState(aa);
        work->startWork();
    }
}

void NoonState::update(std::shared_ptr<Work> work)
{
    if (work->getHour() < 13)
    {
        std::cout << "当前时间:" << work->getHour() << "累了，饿了，困了" << std::endl;
    }
    else
    {
        std::shared_ptr<State> aa(new AfternoonState);
        work->setState(aa);
        work->startWork();
    }
}

void AfternoonState::update(std::shared_ptr<Work> work)
{
    if (work->getHour() < 17)
    {
        std::cout << "当前时间：" << work->getHour() << "等待下班ing" << std::endl;
    }
    else
    {
        std::shared_ptr<State> aa(new EveningState);
        work->setState(aa);
        work->startWork();
    }
}

void EveningState::update(std::shared_ptr<Work> work)
{
    if (!work->getFinished() && work->getHour() < 21)
    {
        std::cout << "当前时间：" << work->getHour() << "苦逼，加班中..." << std::endl;
    }
    else
    {
        std::shared_ptr<State> aa(new SleepState);
        work->setState(aa);
        work->startWork();
    }
}

void SleepState::update(std::shared_ptr<Work> work)
{
    if (work->getHour() > 17 || work->getHour() < 8)
    {
        std::cout << "当前时间：" << work->getHour() << "睡觉中......" << std::endl;
    }
    else
    {
        std::shared_ptr<State> aa(new MorningState);
        work->setState(aa);
        work->startWork();
    }
}
